<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>

<head>
    <base href="${pageContext.request.contextPath}/"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <style>
        /*定义类名为.thead-blue的样式*/
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css"/>
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>
</head>
<body>

<!-- 搜索 -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">单据详情</h4>
    </div>
    <div class="panel-body">
        <div class="col-md-10 col-md-offset-1" style="text-align: center">
            <h4><span class="label label-primary">${approval.emp.empName }</span>
                的
                ${approval.docType=='BXD'?"报销申请单":"" }
                ${approval.docType=='GMD'?"资产购买申请单":"" }
                ${approval.docType=='YDD'?"资产移动申请单":"" }
                <button type="button" class="btn btn-success" onclick="location.href='${docInfoUrl }'">查看申请单详情</button>
                <button type="button" class="btn btn-info" data-toggle="modal" data-target="#docInfoModal">查看审批记录
                </button>
            </h4>
        </div>
    </div>
</div>

<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">单据审批</h4>
    </div>
    <div class="panel-body">
        <form action="flow/doApproval" method="post" class="form-horizontal"
              role="form" id="approvalForm">
            <div class="modal-body">
                <div class="row">
                    <div class="form-group col-md-12">
                        <label for="status" class="col-md-3 control-label">审批状态</label>
                        <div class="col-md-8">
                            <input type="hidden" name="oid" id="oid" value="${approval.oid }">
                            <select id="status" name="status" class="form-control">
                                <option value="">--请选择--</option>
                                <option value="Y">同意</option>
                                <option value="N">不同意</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-12">
                        <label for="opinion" class="col-md-3 control-label">审批意见</label>
                        <div class="col-md-8">
								<textarea class="form-control" id="opinion" name="opinion" rows="5"
                                          placeholder="请输入审批意见"></textarea>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="form-group col-md-12">
                        <div class="col-md-8  col-md-offset-3">
                            <button type="button" onclick="history.back()" class="btn btn-default">返回</button>
                            <button type="submit" id="sub" class="btn btn-primary">确认提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>


<div class="modal fade" id="docInfoModal" tabindex="-1" role="dialog"
     aria-labelledby="docInfoModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">&times;
                </button>
                <h4 class="modal-title" id="docInfoModalLabel">申请单审批记录</h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="form-group col-md-12">
                        <c:forEach items="${listApproval }" var="a" varStatus="i">
                            <div class="col-md-12">
                                <div class="panel panel-primary">
                                    <div class="panel-heading" style="text-align: center">
                                            ${a.node.name}
                                    </div>
                                    <div class="panel-body">
                                        <div class="col-md-7">
                                            <c:if test="${a.node.isByDept=='Y' }">
                                                <span class="text-primary">${a.dept.deptName }经理</span>
                                                <span class="text-danger">${a.approvalEmp.empName }</span> 审批
                                            </c:if>
                                            <c:if test="${a.node.isByDept=='N' }">
                                                <span class="text-primary">${a.node.dept.deptName } -- ${a.node.job.name }</span>
                                                <span class="text-danger">${a.approvalEmp.empName }</span> 审批
                                            </c:if>
                                        </div>
                                        <div class="col-md-5">
                                            <span class="text-success">${a.status=='Y'?"审批通过":"" }</span>
                                            <span class="text-danger">${a.status=='N'?"审批不通过":"" }</span>
                                            <span class="text-warning">${a.status=='S'?"待审批":"" }</span>
                                        </div>
                                        <div class="col-md-12">
                                            &nbsp;
                                        </div>
                                        <div class="col-md-12">
                                            审批意见:${a.opinion }
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6 col-md-offset-3" style="text-align: center">
                                <img src="view/lc/img/next.png" width="38px">
                                <BR><BR>
                            </div>
                        </c:forEach>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

<br>
<br>
<br>

<%@include file="../modal/confirm.jsp" %>
<%@include file="../modal/alertmsg.jsp" %>
<script type="text/javascript">
    $(document).ajaxError(function (event, xhr) {
        if (xhr.status == "403") {//没有权限
            document.location.href = xhr.getResponseHeader("url");
        } else if (xhr.status != "200") {
            //alert("服务器错误!");
            console.log("服务器错误!");
        }
    });
</script>


</body>
<script type="text/javascript">
    $(document).ready(function () {
        $("#approvalForm").bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/*input状态样式图片*/
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                status: {
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '请选择审批状态'
                        }
                    }
                },
                opinion: {
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '请填写审批意见'
                        }
                    }
                }
            },
            submitHandler: function (validator, form, submitButton) {
                validator.defaultSubmit();
            }
        });
    });
</script>
</html>